refactor(ui): WebUI modernization PR5 — ES module split - #113
Closed
jkyberneees wants to merge 1 commit into
Closed
Conversation
Split the ~2.4k-line app.js IIFE into native ES modules under cmd/odek/ui/js/ (no build step, no dependencies). app.js stays the /app.js entry and now just imports ./js/main.js. - js/state.js: single mutable state object S (all former module-level globals) + session-token persistence helpers - js/dom.js / js/net.js: import-free leaves (getElementById refs, getWsToken/apiHeaders) - js/utils.js / js/markdown.js: pure helpers and markdownToHtml - js/render.js: streaming, thinking, tool blocks, sub-agents, session history, collapse/copy, loading indicator; addMessage monkey-patch dissolved into direct addCopyButton/checkCollapse calls - js/approvals.js / js/sessions.js / js/input.js / js/ws.js / js/main.js: approval queue, sidebar, prompt/attachments/@-completion, WebSocket dispatch, init sequence - All inline onclick/onchange handlers (index.html and generated HTML) replaced with addEventListener / click delegation on #messages; window.* exports removed - serve.go handleStatic: sanitized /js/<file>.js route (rejects .., subdirs, non-.js) served from the embedded uiFS
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
odek | 2f2968f | Commit Preview URL Branch Preview URL |
Jul 26 2026, 01:12 PM |
This was referenced Jul 26, 2026
feat(ui): WebUI modernization PR6 — streaming-safe markdown tokenizer, golden tests, strict CSP
#114
Closed
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fifth PR of the WebUI modernization roadmap — Phase 3a: ES-module split. Stacked on #112 (
feat/webui-modernization-4). Pure re-architecture: zero behavior, styling, or protocol changes.The 2,408-line
app.jsIIFE (with ~40 mutable globals and ~50 functions, inlineonclickhandlers everywhere, and a monkey-patchedaddMessage) becomes native ES modules undercmd/odek/ui/js/— still no build step, no dependencies, still embedded viaembed.FS:net.jsgetWsToken,apiHeadersdom.jsgetElementByIdrefsstate.jsSobject holding every former global (live-binding friendly);kode_*→odek_*migration; session-token persistence incl.ensureSessionTokenutils.jspruneMessages, small DOM toggles (showCancel/hideCancel/scrollToBottom/toggleShortcuts— placed here to keep the import graph acyclic)markdown.jsmarkdownToHtmlverbatim (tokenizer rewrite is the next PR)render.jsresetTurnStateapprovals.jssessions.jsinput.jsws.jsconnect()+ the full WS event switch + event handlersmain.jsui/app.jsis now a 4-line entry importing./js/main.js;index.htmlloads it withtype="module".Inline handlers eliminated. Every
onclick/onchangeattribute (index.html + generated HTML) and everywindow.foo =export is gone, replaced byaddEventListenerand a single click-delegation listener on#messages(tool blocks, thinking toggles, sub-agent details, result expanders, code/message copy, collapse toggles). This unblocks the strict CSP in the next PR. TheaddMessagemonkey-patch was dissolved into direct calls.Server route:
serve.gogains a sanitized/js/<file>.jsroute (rejects.., subdirectories, non-.js) serving from the embeddedui/js/.Verification
node --checkon all 12 files ✅; no leftover inline handlers or unqualified old globals ✅go build,go vet, fullcmd/odektest suite ✅odek serve:/,/app.js, all 9 module files → 200;/js/evil.txt→ 404; traversal rejected ✅